
//
//  MOWorkTaskDetailViewController.m
//  MobileOffice
//
//  Created by 冰冰 on 2019/8/16.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#import "MOWorkTaskDetailViewController.h"
#import "MOWorkTaskDetailModel.h"

@interface MOWorkTaskDetailViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *tableView;

@property(nonatomic,strong)NSMutableArray *dataSource;

@property(nonatomic,strong)UIView *footerView;

@property(nonatomic,strong)UILabel *taskTargetLabel;

@property(nonatomic,strong)UILabel *taskTargetValueLabel;

@property(nonatomic,strong)UILabel *taskContentValueLabel;

@end

@implementation MOWorkTaskDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self creatView];
    
    [self initData];
}

-(void)creatView
{
    self.title = @"任务详情";
    
    self.view.backgroundColor = KWhiteColor;
    
    [self.view addSubview:self.tableView];
    self.tableView.tableFooterView = self.footerView;
}

-(void)initData
{
    self.dataSource = [NSMutableArray array];
    NSArray *arr = @[@"任务名称\t",@"人员姓名\t",@"年度\t\t",@"发布时间\t",@"完成时间\t",@"所属部门\t"];
    NSArray *vArr = @[@"关于数字人事系统学习",@"刘宏疆",@"2019",@"2019.09.20 09:20:56",@"2019.09.20 09:20:56",@"机关后勤"];
    for (int i = 0; i<arr.count; i++) {
        MOWorkTaskDetailModel *model = [[MOWorkTaskDetailModel alloc]init];
        model.nameStr = arr[i];
        model.valueStr = vArr[i];
        [self.dataSource addObject:model];
    }
    [self.tableView reloadData];
}

#pragma mark -- UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataSource.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"cell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.textColor = KBlackColor_222222;
        cell.textLabel.font = FONT_SIZE(15);
    }
    
    MOWorkTaskDetailModel *model = self.dataSource[indexPath.row];
    cell.textLabel.attributedText = [NSString contentString:[NSString stringWithFormat:@"%@%@",model.nameStr,model.valueStr] subString:model.valueStr subColor:KGrayColor_919395 subFont:FONT_SIZE(15)];
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kHConversions(54);
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.8;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 13;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return nil;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return nil;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}

#pragma mark - 设置顶头分割线
-(void)viewDidLayoutSubviews {
    
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    }
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])  {
        if (@available(iOS 8.0, *)) {
            [self.tableView setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 0)];
        } else {
            // Fallback on earlier versions
        }
    }
}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPat{
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        if (@available(iOS 8.0, *)) {
            [cell setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 0)];
        } else {
            // Fallback on earlier versions
        }
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    }
}


#pragma mark -懒加载
-(UITableView *)tableView
{
    if (!_tableView) {
        
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-StatusBarAndNavigationBarHeight) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = KGrayColor_ededed;
        _tableView.showsVerticalScrollIndicator = NO;
        
    }
    return _tableView;
}

-(UIView *)footerView
{
    if (!_footerView) {
        _footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1)];
        
        
        
    }
    return _footerView;
}



@end
